/*
 * @Description: 
 * @Version: 1.0
 * @Author: Dandelion
 * @Date: 2018-03-22 23:00:41
 * @LastEditTime: 2021-10-28 21:09:29
 * @FilePath: \USERc:\Users\24828\Desktop\F1灯条程序\HARDWARE\ws2812\WS2812B.h
 */
#ifndef __WS2812B_H
#define	__WS2812B_H

#include "stm32f10x.h"
#include "delay.h"	

#define WS_HIGH 45
#define WS_LOW  30

enum Status_of_LED
{
    RED_ON = 0,
    GRENN_ON,
    BLUE_ON,
    ALL_CLOSE,
    rainbow,//彩虹模式（不知道与cycle模式具体有什么不同，待测试）
    rainbow_cycle,//让彩虹均匀分布在整个区域
    theater_chase,//剧院模式（三个三个一组以一个颜色）
    theater_chase_rainbow,//剧院彩虹模式（三个三个一组以RGB彩虹模式）
    color_wipe,//依次点亮
};

typedef struct _WS2812LED
{
    /* data */
    u8 pixel_num;
    u8 GRB;
    uint16_t pixelBuffer[20][24];
    u8 status; 

    void (* WS281x_Show)(void);
} WS2812LED;

void WS281x_Init(GPIO_TypeDef *gpiox, u8 io_num, WS2812LED *led_line_num);
void WS281x_CloseAll(WS2812LED *led_line);
uint32_t WS281x_Color(uint8_t red, uint8_t green, uint8_t blue);
void WS281x_SetPixelColor(uint16_t n, uint32_t GRBColor, WS2812LED *led_line);
void WS281x_SetPixelRGB(uint16_t n ,uint8_t red, uint8_t green, uint8_t blue, WS2812LED *led_line);
void WS281x_Show_Line1(void);
void WS281x_Show_Line2(void);
void WS281x_Show_Line3(void);
void WS281x_Show_Line4(void);

uint32_t WS281x_Wheel(uint8_t wheelPos);
void WS281x_RainbowCycle(uint8_t wait, WS2812LED *led_line);
void WS281x_TheaterChase(uint32_t c, uint8_t wait, WS2812LED *led_line);
void WS281x_ColorWipe(uint32_t c, uint8_t wait, WS2812LED *led_line);
void WS281x_Rainbow(uint8_t wait, WS2812LED *led_line);
void WS281x_TheaterChaseRainbow(uint8_t wait, WS2812LED *led_line);

void LED_Line_Mode_Choose(WS2812LED *led_line_num);

extern WS2812LED led_line_1, led_line_2, led_line_3, led_line_4;

#endif /* __LED_H */
